<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>DRWord--修改密码</title>
<link href="{{ url_for('static', filename='Wopop_files/style_log3.css') }}" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='Wopop_files/style.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='Wopop_files/userpanel.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='Wopop_files/jquery.ui.all.css') }}">

<script src="{{ url_for('static', filename='js/jquery-3.3.1.min.js') }}"></script>

</head>

<body class="login" mycollectionplug="bind">
<div class="login_m">
  <div class="login_logo"><img src="{{ url_for('static', filename='Wopop_files/login2.png') }}" width="235" height="56"></div>
  <div class="login_boder">

     <div class="login_padding" id="login_model">

       
        <h2>用户名</h2>
        <label>
            <input type="text" id="username" name="username" class="txt_input " required="required"   disabled="true" >
        </label>

        <h2>原密码</h2>
        <label>
            <input id="oldpassword" type="password" name="password"  class="txt_input" required="required"  placeholder="请输入原密码！">
        </label>

        <h2>新密码</h2>
        <label>
            <input id="newpassword" type="password" name="password"  class="txt_input" required="required"  placeholder="请输入新密码！">
        </label>

        <h2>再次确认</h2>
        <label>
            <input id="newchecknumber" type="password" name="checknumber" class="txt_input" required="required"  placeholder="请再输入一次新密码！">
        </label>

        <p class="forgot"><a id="iforgot" href="/index">返回主页</a></p>

        <div class="rem_sub" >
          <!-- 登录-->          
              <input type="button" class="sub_button" name="submit" id="submit" value="确认修改" 
                style="opacity: 0.7;" >    
        </div>  
       
     </div>
  </div>

</div>
 <br><br><br><br><br><br><br>
<p align="center"> More Infomation <a href="http://www.xjtu.edu.cn/" >XJTU</a> - Designed by <a href="" title="" target="_blank">WSW</a></p>
<br><br>






<!-- javascript代码-->
<script type="text/javascript">

$(document).ready(function(e){

var username = document.cookie.substring(9);
document.getElementById('username').value = username;

$("#submit").click(function(){
  /*
   var UserName = document.forms["registerform"]["username"];
   var PassWord = document.forms["registerform"]["password"]; 
   var CheckNumber = document.forms["registerform"]["checknumber"];
  */
   var UserName = $("#username").val();
   var newPassWord = $("#newpassword").val();
   var newCheckNumber = $("#newchecknumber").val();

    if(newPassWord != newCheckNumber){
      alert('password and checkword are not equal!');
      //PhoneNumber.value="";
      newCheckNumber.value="";
      return false;  
    }
    else{

      //两次密码正确，则调用Ajax上传数据
      var username = $("#username").val();
      var oldpassword = $("#oldpassword").val();
      var newpassword = $("#newpassword").val();
      //var newchecknumber = $("#newchecknumber").val();
      var registerjson={"username":username,"oldpassword":oldpassword,"newpassword":newpassword};
    $.ajax({

        //url:"http://115.154.137.49:5000/update_password",
        url:"http://192.168.31.103:5000/update_password",
        //处理页面的路径
        data:JSON.stringify(registerjson),
        //传递的数据.提交数一般以json格式来写,key是自定义的,:后面的值 就是上面的值
        type:"POST",
        //数据的提交传递方式,GET,POST 最好用POST
        datatype:"TEXT",
        //返回值的类型,TEXT,JSON,XML三种类型可选
        success:function(data){
        //如果ajax执行成功,返回来调用success函数即回调函数,返回值以参数的形式返回
        
        if(data=="OK")
        {
            alert('修改成功')
            window.location.href="/login";
            return true;
        }
        else
        {
            alert(data);
            return false;
        }
        
        },

    });

    }
  
})
});

</script>




</body>
</html>